//package com.plian.system.service.tb.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.TokenUtil;
//import com.plian.system.constant.tb.TripleStatusConstant;
//import com.plian.system.entity.tb.TopicRelevance;
//import com.plian.system.entity.tb.TripleEvent;
//import com.plian.system.entity.tb.TripleSystem;
//import com.plian.system.mapper.tb.TopicRelevanceMapper;
//import com.plian.system.mapper.tb.TripleEventMapper;
//import com.plian.system.mapper.tb.TripleSystemMapper;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.service.tb.ITopicRelevanceService;
//import com.plian.system.service.tb.ITripleEventService;
//import com.plian.system.service.tb.ITripleSystemService;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @Author: Take-off
// * @Description: TODO 会议列席人
// * @Date: 2022/12/29 2:04 PM
// * @Version: 1.0
// **/
//@Service
//@AllArgsConstructor
//public class TopicRelevanceServiceImpl extends BaseServiceImpl<TopicRelevanceMapper, TopicRelevance> implements ITopicRelevanceService {
//
//    private TripleEventMapper eventMapper;
//
//    private TripleSystemMapper systemMapper;
//
//    private final ITripleSystemService tripleSystemService;
//
//    private final ITripleEventService tripleEventService;
//
//    @Override
//    public boolean deleteLogic(List<Long> ids) {
//        //关联信息
//        List<TopicRelevance> topicRelevances =listByIds(ids);
//        if (CollectionUtil.isNotEmpty(topicRelevances)){
//            //修改事项状态
//            List<Long> eventIds = topicRelevances.stream().filter(m -> m.getRelevanceType() == 1).map(TopicRelevance::getRelevanceId).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(eventIds)){
//                tripleEventService.changeStatus(eventIds,TripleStatusConstant.LATER);
//            }
//            //修改制度状态
//            List<Long> systemIds = topicRelevances.stream().filter(m -> m.getRelevanceType() == 2).map(TopicRelevance::getRelevanceId).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(systemIds)){
//                tripleSystemService.changeStatus(systemIds,TripleStatusConstant.LATER);
//            }
//        }
//
//
//        boolean result = super.deleteLogic(ids);
//
//        return result;
//    }
//
//    @Override
//    public boolean deleteByTopicId(List<Long> ids) {
//        LambdaQueryWrapper<TopicRelevance> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.in(TopicRelevance::getTopicId, ids);
//        List<TopicRelevance> topicRelevances = list(queryWrapper);
//        if (CollectionUtil.isNotEmpty(topicRelevances)){
//            return deleteLogic(topicRelevances.stream().map(TopicRelevance::getId).collect(Collectors.toList()));
//        }
//        return true;
//    }
//
//    @Override
//    public boolean deleteByMeetingId(List<Long> ids) {
//        LambdaQueryWrapper<TopicRelevance> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.in(TopicRelevance::getBaseMeetingId, ids);
//        List<TopicRelevance> topicRelevances = list(queryWrapper);
//        if (CollectionUtil.isNotEmpty(topicRelevances)){
//            return deleteLogic(topicRelevances.stream().map(TopicRelevance::getId).collect(Collectors.toList()));
//        }
//        return true;
//    }
//
//    @Override
//    public List<TopicRelevance> getAllRelevance(){
//        List<TopicRelevance> topicRelevances = new ArrayList<>();
//        String orgId = TokenUtil.getTokenOrgId();
//        List<TripleEvent> tripleEvents = eventMapper.selectList(new LambdaQueryWrapper<TripleEvent>().eq(TripleEvent::getEventStatus, TripleStatusConstant.LATER));
//        if (CollectionUtil.isNotEmpty(tripleEvents)){
//            tripleEvents.forEach(event ->{
//                TopicRelevance relevance = new TopicRelevance();
//                relevance.setRelevanceId(event.getId());
//                relevance.setRelevanceName(event.getEventName());
//                relevance.setRelevanceCode(event.getEventNumber());
//                relevance.setRelevanceType(1);
//                topicRelevances.add(relevance);
//            });
//        }
//        List<TripleSystem> tripleSystems = systemMapper.selectList(new LambdaQueryWrapper<TripleSystem>().eq(TripleSystem::getSystemStatus, TripleStatusConstant.LATER));
//        if (CollectionUtil.isNotEmpty(tripleSystems)){
//            tripleSystems.forEach(system ->{
//                TopicRelevance relevance = new TopicRelevance();
//                relevance.setRelevanceId(system.getId());
//                relevance.setRelevanceName(system.getSystemName());
//                relevance.setRelevanceCode(system.getSystemNumber());
//                relevance.setRelevanceType(2);
//                topicRelevances.add(relevance);
//            });
//        }
//
//        return topicRelevances;
//    }
//
//
//}
